package problem.nc007;

public class Solution {
    /**
     *
     * @param prices int整型一维数组
     * @return int整型
     */
    public int maxProfit (int[] prices) {
        int low = prices[0];
        int max = 0;

        for(int i : prices){
            if(i < low){
                low = i;
            }

            if(i > low){
                max = Math.max(max,i - low);
            }
        }

        return max;
    }
}
